package com.lx.service;

import com.lx.annotation.DataSource;
import com.lx.common.ContextConst;
import com.lx.entity.User;
import com.lx.mapper.UserMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 使用主数据源服务类
 *
 * @author 段誉
 * @create 2019-04-12 16:20
 */
@Service
public class ParmaryUserServiceImpl implements ParmaryUserService {
  @Autowired
  private UserMapper userMapper;

  /**
   * 默认数据源
   */
  @Override
  public User selDefault() {
    return userMapper.userQuery(1);
  }

  /**
   * 指定使用Prod数据源
   */
  @DataSource(ContextConst.DataSourceType.PROD)
  @Override
  public User selProd() {
    return userMapper.userQuery(1);
  }

  /**
   * 使用Local数据源
   */
  @DataSource(ContextConst.DataSourceType.LOCAL)
  @Override
  public User selLocal() {
    return userMapper.userQuery(1);
  }
}
